<template>
	<div>
		<div @click="clearselect">清空</div>
		<datapick :ref="'s_'+sid" :right="right" flag="l" @datechange1="changeleft" @errs1="showerr"></datapick>
		<datapick2 :ref="'su_'+sid" :left="left" flag="r" @datechange2="changeright" @errs2="showerr"></datapick2>
		<div v-if="errflag" style="color: red;">右边时间不能小于左边时间</div>
	</div>
</template>

<script>
	import datapick from './datepicker.vue'
	import datapick2 from './datepicker_.vue'
	export default {
		data(){
			return {
				left:'',
				right:'',
				errflag:0
			}
		},
		props:{
			sid:{
				type:null,
				default:null
			}
		},
		components:{
			datapick,
			datapick2
		},
		methods:{
			changeleft:function(e){
				this.left = e
				if(this.left && this.right) {
					//同时发射出去修改外面的
					console.log(this.left + '~' + this.right)
				}
			},
			changeright:function(e){
				this.right = e
				if(this.left && this.right) {
					//同时发射出去修改外面的
					console.log(this.left + '~' + this.right)
				}
			},
			showerr:function(){
				this.errflag = 1
				setTimeout(()=>{
					this.errflag = 0
				},3000)
			},
			clearselect:function(){
				//同时发射出去修改外面的和里面的
				this.left = null
				this.right = null
				this.$refs['s_'+this.sid].upTower = ''
				this.$refs['su_'+this.sid].upTower = ''
			}
		}
	}
</script>

<style>
</style>
